﻿@model QuanLyGiaoVuUI.Models.GiangVienClient.DangKyGioDayGiangVienClientViewModel
@{
    ViewBag.Title = "DangKyGioDay";
    Layout = "~/Views/Shared/_GiangVienClientLayout.cshtml";
}

<div id="gv-main-wrapper">
    @{Html.RenderPartial("GiangVienClientGiangDayMenuPartial");}


    <div id="main" class="grid_10 gvclientmain">
        <!--  start page-heading -->

        <div id="page-heading" class="box round first grid">
            <h2>ĐĂNG KÝ GIỜ GIẢNG DẠY</h2>
            <!-- end page-heading -->

            <div id="gvclientmaincontent" class="block">                
                <div>
                    <table class="gridtable" cellspacing="0" border="1" bordercolor="#000000" width="100%">
                        <thead>
                            <tr>
                                <th style="width: 250px;">Chọn Lớp</th>
                                <th style="width: 100px;">Chọn Thứ</th>
                                <th style="width: 100px;">Chọn Ca</th>
                                <th style="width: 200px;">Chọn độ Ưu Tiên</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tr>
                            <td>@*@Html.DropDownList("chonlop", new SelectList(Model.DanhSachLopMonHoc, "LopMonHocId","MonHoc.TenMonHoc"))*@
                                <select id="chonlop">
                                    @foreach (var lopmonhoc in Model.DanhSachLopMonHoc)
                                    {
                                        <option value="@lopmonhoc.LopMonHocId">@lopmonhoc.MonHoc.MaMonHoc - @lopmonhoc.MonHoc.TenMonHoc</option>
                                    }
                                </select>
                            </td>
                            <td>
                                <select id="chonthu">
                                    <option value="2">Thứ 2</option>
                                    <option value="3">Thứ 3</option>
                                    <option value="4">Thứ 4</option>
                                    <option value="5">Thứ 5</option>
                                    <option value="6">Thứ 6</option>
                                    <option value="7">Thứ 7</option>
                                </select>
                            </td>
                            <td>
                                @Html.DropDownList("chonca", new SelectList(Model.DanhSachCa, "MaCa", "TenCa"))
                            </td>
                            <td>
                                <select id="chondouutien">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                </select>
                            </td>
                            <td><a href="#" id="dangkygiogiangday">ĐĂNG KÝ</a></td>
                        </tr>
                    </table>
                </div>
                <br />
                <br />
                <hr />
                <br />
                <div id="thongtindangkygioday">
                </div>
                <br />
                <br />
                @*<h2>Môn được phần công</h2>
<div>
    @{Html.EnableClientValidation();}
    @using (Ajax.BeginForm("LopMonHoc", "GiangVienClient", new AjaxOptions { HttpMethod = "POST" }))
    {
        int i = 1;          
        @Html.ValidationSummary(true)
        <table id="gvLopMonHoc">
            <thead>
                <tr id="gvLopMonHocTd">
                    <td class="textcenter" style="width: 50px;">STT</td>
                    <td class="textcenter" style="width: 100px;">Mã Lớp</td>
                    <td class="textcenter" style="width: 200px;">Tên Môn Học</td>
                    <td class="textcenter" style="width: 100px;">Loại Lớp</td>
                    <td class="textcenter" style="width: 100px;">SS.Tối Đa</td>
                    <td class="textcenter" style="width: 50px;">Thứ</td>
                    <td class="textcenter" style="width: 50px;">Ca</td>
                </tr>
            </thead>
            
            @foreach (var lopmonhoc in Model.DanhSachLopMonHoc)
            {
                <tr>
                    <td class="textcenter">@i</td>
                    <td class="textcenter">@lopmonhoc.MaLopMonHoc</td>
                    <td class="textcenter">@lopmonhoc.MonHoc.TenMonHoc</td>
                    <td class="textcenter">@lopmonhoc.LoaiLopMonHoc.TenLoaiLopMonHoc</td>
                    <td class="textcenter">@lopmonhoc.SiSoToiDa</td>
                    <td class="textcenter" id="Thu">@lopmonhoc.Thu</td>
                    <td class="textcenter">@lopmonhoc.TietDau.TietThu</td>                                                                             
                </tr>
                    i++;
            }
        </table>
    }
</div>*@
            </div>
        </div>
    </div>

    <div class="clear">&nbsp;</div>

</div>



<script>
    $(document).ready(function () {
        $('#thongtindangkygioday').load("/GiangVienClient/LayThongTinDangKyGioDay");
        $('#chondouutien').change(function () {
            var malop = $('#chonlop').val();
            var thu = $('#chonthu').val();
            var maca = $('#chonca').val();
            var douutien = $('#chondouutien').val();
            var isChecked = true;
            $.post("DangKyGioDay", { malopmonhoc: malop, thu: thu, maca: maca, douutien: douutien, isCheckExisted: isChecked }, function (data) {
                if (data.success == true) {
                    //alert("Thành Công!");
                }
                else {
                    alert(data.message);
                }
            });
        });
        $('#dangkygiogiangday').click(function () {
            var malop = $('#chonlop').val();
            var thu = $('#chonthu').val();
            var maca = $('#chonca').val();
            var douutien = $('#chondouutien').val();
            var isChecked = false;
            if (malop == null || malop == "") {
                alert("Bạn chưa được phân công lớp nào!");
                return;
            }
            else {
                $.post("DangKyGioDay", { malopmonhoc: malop, thu: thu, maca: maca, douutien: douutien, isCheckExisted: isChecked }, function (data) {
                    if (data.success == true) {
                        alert(data.message);
                        $('#thongtindangkygioday').load("/GiangVienClient/LayThongTinDangKyGioDay");
                    }
                    else {
                        alert(data.message);
                    }
                });
            }
            //alert("malop:" + malop + "thu:" + thu + "maca:" + maca + "douutien:" + douutien);
        });
        //$('.xoadangky').click(function () {
        //    var maDangKy = $(this).attr("rel");
        //    //alert(maDangKy);
        //    $.post("XoaThongTinDangKyGioDay", {thongtindkID:maDangKy}, function (data) {
        //        if (data.success == true) {
        //            alert("Xóa Thành Công!");
        //            $('.' + maDangKy).remove();
        //        }
        //        else {
        //            alert("Xóa Không Thành Công!");
        //        }
        //    });
        //});
    });
</script>
